package Runde4;

public class MyQueue {
	
	private MyQueueElement first;
	
	/**
	 * @precondition - node!=null;
	 * @postcondition - Adds given node to queue if node (If node==null, nothing will be added)
	 * @param node - node which will be added to queue
	 */
	public void push(Node node) {
		if (node != null) {
			MyQueueElement el = new MyQueueElement(node);
			if (first != null) {
				MyQueueElement current = first;
				while (!(current.getNextElement() == null)) {
					current = current.getNextElement();
				}
				current.setNextElement(el);
			} else {
				first = el;
			}
		}
	}
	
	/**
	 * @postcondition - Returns first QueueElement's Node (first Node in Queue)
	 */
	public Node pop() {
		Node valToReturn = first.getElementContent();
		first = first.getNextElement();
		return valToReturn;
	}
}
